<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of WrapperApp
 *
 * @author EaDeveloper
 */
class AppWrapper implements EaSoftModule {

    public $title = "Principal";
    public $module = null;
    public $db;
    public $sec = null;
    public $instanceName = "MainApp";

    function __construct() {
        $this->sec = new AppSecurity();        
    }

    public function showMenu() {
        include MODULES . DS . "app/menu.php";
    }

    public function getCssFiles() {
        if ($this->module != null) {
            $this->module->getCssFiles();
        }
    }

    public function getJsFiles() {
        if ($this->module != null) {
            $this->module->getJsFiles();
        }
    }

    public function getWindowTitle() {
        if ($this->module != null) {
            return $this->title . " / " . $this->module->getWindowTitle();
        }
        return $this->title;
    }

    public function main() {
        $this->sec->db = $this->db;
        if (!isEmpty("start")) {
            $this->sec->usuarioValido();
        }

        $this->checkSeguridad();
    }

    public function checkSeguridad() {
        if (!isset($_SESSION[USUARIO])) {
            $this->sec->main();
        } else {
            if ($this->module instanceof AppSecurity) {
                $this->module = null;
            }
            $logoPrt = PortletFactory::getPortlet("portletimgloader");
            $logoPrt->image = "ebook.jpeg";
            include MODULES . DS . "app/main.php";
            PortletFactory::rewritePorlet($logoPrt);
        }
    }

}

?>
